#ifndef MODEL_DISPLAY_H
#define MODEL_DISPLAY_H

#include <FL/Fl_Gl_Window.H>
#include <vector>
#include "d_Camera.h"
#include "camera.h"
#include "a48.h"
#include "PADSMesh.h"

using namespace A48;
using namespace std;

class ModelDisplay : public Fl_Gl_Window
{
public:
	ModelDisplay(int x, int y, int w, int h, char *l);
	~ModelDisplay()
	{
		delete mesh;
		delete pads_mesh;
		delete patch_file;
		delete texture_file;
		delete color_file;
		delete filename;
		delete cam_files;
		delete img_files;
		delete cameras;
		delete camera;
	}
	void draw();
	Mesh *mesh;
	PADSMesh *pads_mesh;
	int draw_mode;
	char *patch_file;
	char *texture_file;
	char *color_file;
	char *filename;
	char **cam_files;
	char **img_files;
	int num_cams;
	int num_patches;
	int look_through;
	int draw_patch;
	float splat_size;
	bool draw_cameras;
	bool draw_axis;
	bool wireframe;
	bool dont_draw;
	VCGCamera **cameras;
	void v_angle(float value){vAng=value;}
	void h_angle(float value){hAng=value;}
	void panx(float value){xPan=value;}
	void pany(float value){yPan=value;}
	void zoom(float value){zoom_factor=value;}
	void loadFile();
	void resetTrans();
	void update();
	void drawPatch(int index);
	void take_screenshot(char *screen_file);
	void generateDS();
	void load_texture(char *filename);
	void get_camera_center();
	d_Camera *camera;
	d_Vec3f object_center;
private:
	bool has_texture;
	GLuint texture;
	float vAng, hAng;
	float xPan, yPan;
	float zoom_factor;
	void drawAxis();
	void drawMesh();
	void drawCameras();
	void loadMesh(char *file);
	Vec3 faceNormal(Face *f);
	void computeNormals();
	int handle(int event);
	void computeBsphere();
};

#endif

